The present invention relates to data processing by digital computer, and more particularly to a defining and using data types in a computer program executed by a digital computer.
A computer program provides instructions to direct and control the operation of a digital computer. A digital computer will be referred to as a computer. The instructions of a computer program may be developed using a programming language. In this specification, the use of the term instruction is not limited to a single machine-executable instruction. The term “instruction” is used as a convenience for the many ways in which a computer may be programmatically directed to perform a particular action. For example, instructions may be executed through the actions of an interpreter or a virtual machine running on a computer.
Programming languages may be classified in a variety of ways. In this specification, procedural programming languages are distinguished from functional programming languages. In a procedural programming language, programs are generally expressed as a sequence of statements and the order of statements affects the order in which the statements are performed. Examples of an procedural languages include COBOL, Fortran, and C.
By contrast, the statements of a computer program developed in a functional programming language represent a collection of functions such that each function has an input and a result. A function in the collection interacts with other functions in the collection to produce a result. Thus, a computer program written in a functional programming language is not programmed as a sequence of steps or operations. Haskell is an example of a functional programming language.
Some programming languages only allow data types known at compile time to be used for data typing—that is, checking to ensure that the use of a data object is consistent with the data type of the data object. An advantage of such compile-time data typing is the imposition of a set of rules on a programmer, which helps reduce programming errors. A disadvantage of such compile-time data typing is that only data types known at compile time may be used.
In most statically-typed programming languages, data types are only used at design-time to support the programmer in creating correct programs and discover errors during the development phase. As such, data types in statically-typed programming languages generally are not used at runtime. However, some statically-typed programming languages have the capability to use and check a generic data type, which is a partially-defined data type. In the programming language ABAP, for example, a generic data type defines a generic data structure (such as a table) without defining all the details, such as the particular types of data elements within the data structure. In such a case, only limited use checking can be performed. For example, the compiler can detect the error of a Boolean operation being performed on a generic table type, but it cannot detect errors related to the data type of a particular column, which is not know at compile time.